//package org.example.virtualsensors.config;
//
//import org.example.virtualsensors.entity.model.Sensor;
//import org.example.virtualsensors.service.SensorDataService;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.util.Random;
//
//@Component
//public class SchedulerConfig {
//    private final SensorDataService sensorDataService;
//    private final Random random = new Random();
//
//    public SchedulerConfig(SensorDataService sensorDataService) {
//        this.sensorDataService = sensorDataService;
//    }
//
//    @Scheduled(fixedRate = 5000)  // 每5秒生成一次实时数据
//    public void generateSensorData() {
//        String[] sensorKeys = {"S001", "S002", "S003", "S004", "S005"};
//        String hostSn = "SN123456";  // 主机序列号
//
//        for (String sensorKey : sensorKeys) {
//            Sensor sensorData = new Sensor();
//            sensorDataService.updateSensorData(sensorData);  // 更新缓存
//        }
//        System.out.println("实时数据已更新");
//    }
//}